// import Vue from 'vue'
// import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

// Vue.use(VueRouter)

// const routes = [
//   {
//     path: '/',
//     name: 'Home',
//     component: Home
//   },
//   {
//     path: '/about',
//     name: 'About',
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
//   }
// ]

// const router = new VueRouter({
//   mode: 'history',
//   base: process.env.BASE_URL,
//   routes
// })

// export default router
import Vue from "vue"
import VueRouter from "vue-router"

// 0 模块化编程 全局注册声明使用 vue-router
Vue.use(VueRouter)

// 1.定义路由组件
import Home from "@/views/Home.vue"

// 2.定义路由选项对象 path component

const routes = [
    {
        path: "/",
        redirect: "/home"
    },
    {
        path: "/home",
        name: "home",
        component: Home
    },
    {
        path: "/find",
        name: "find",
        component: () => import("@/views/Find.vue") /* 路由懒加载 */
    },
    {
        path: "/mine",
        name: "mine",
        component: () => import("@/views/Mine.vue")
    },
    {
        path: "/vuex",
        name: "vuex",
        component: () => import("@/views/Vuex.vue")
    },
    {
        path: "*",
        redirect: {
            name: "home"
        }
    }
]

// 3.创建路由实例对象
const router = new VueRouter({
    routes,
    mode: "history"
})

// 4.挂载到根实例
export default router